import 'package:flutter/material.dart';

class ZsnHeader extends StatelessWidget {
  final String title;
  final bool fullScreen;
  const ZsnHeader({super.key, this.title = '', this.fullScreen = false});

  @override
  Widget build(BuildContext context) {
    return Positioned(
      top: 0,
      left: 0,
      child: Container(
        width: MediaQuery.of(context).size.width,
        padding: fullScreen
            ? EdgeInsets.only(
                left: 20,
                right: 20,
                // 系统状态栏高度
                top: 10,
                bottom: 10,
              )
            : EdgeInsets.all(10),
        // 背景色从上到下渐变
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            // ignore: deprecated_member_use
            colors: [Colors.black.withOpacity(0.5), Colors.transparent],
          ),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            // 左侧返回按钮 标题
            Row(
              children: [
                GestureDetector(
                  child: Icon(Icons.arrow_back, color: Colors.white),
                  onTap: () {
                    Navigator.pop(context);
                  },
                ),
                SizedBox(
                  width: 10,
                ),
                SizedBox(
                  width: MediaQuery.of(context).size.width - 100,
                  child: Text(
                    title,
                    style: TextStyle(
                        color: Colors.white,
                        fontSize: 15,
                        fontWeight: FontWeight.bold,
                        letterSpacing: 1,
                        overflow: TextOverflow.ellipsis),
                  ),
                )
              ],
            ),
            // 右侧更多按钮
            GestureDetector(
              child: Icon(Icons.more_vert, color: Colors.white),
              onTap: () {
                print('点击了更多');
              },
            ),
          ],
        ),
      ),
    );
  }
}
